﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UserDesigner;
using System.IO;
using DevExpress.XtraReports.UI;
using Reports;

namespace Reports
{
    public partial class FrmReportView : Form
    {

        #region Variables
        private XtraReport XReport;
        public DataTable _dtDataSource = new DataTable();
        public string _reportName = string.Empty;
        #endregion

        #region Inits
        public FrmReportView()
        {
            InitializeComponent();
        }
        #endregion

        #region GetReportPath(XtraReport fReport, string ext)

        private static string GetReportPath(XtraReport fReport, string ext)
        {
            System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
            string repName = fReport.Name;
            if (repName.Length == 0)
                repName = fReport.GetType().Name;
            string dirName = Path.GetDirectoryName(asm.Location);
            return Path.Combine(dirName, String.Format("{0}.{1}", repName, ext));
        }

        #endregion

        #region Rác

        //#region _load_XtraTheDocGia

        //public void _load_XtraTheDocGia(DataTable _dtData, string _Madocgia, string _Hovaten, string _Ngaysinh, string _Nghenghiep
        //                                                , string _Diachi, string _Ngayhieuluc, string _Ngayhethan, string _Ngayky)
        //{
        //    _dtDataSource = _dtData;
        //    this.Text = "Cấp Thẻ Đọc Giả";
        //    XtraReports.XtraTheDocGia prints = new XtraReports.XtraTheDocGia();
        //    XReport = prints;
        //    if (File.Exists(GetReportPath(XReport, "repx")))
        //        XReport.LoadLayout(GetReportPath(XReport, "repx"));
        //    prints.Init_XtraTheDocGia(_dtData, _Madocgia,  _Hovaten,  _Ngaysinh,  _Nghenghiep ,  _Diachi,  _Ngayhieuluc,  _Ngayhethan,  _Ngayky);
        //    printControl.PrintingSystem = prints.PrintingSystem;
        //    prints.CreateDocument();
        //}

        //#endregion

        //#region _load_XtraDanhSachDocGiaBiKhoaThe

        //public void _load_XtraDanhSachDocGiaBiKhoaThe(DataTable _dtData, string _Ngayky)
        //{
        //    _dtDataSource = _dtData;
        //    this.Text = "Danh sách đọc giả bị khóa thẻ";
        //    XtraReports.XtraDanhSachDocGiaBiKhoaThe prints = new XtraReports.XtraDanhSachDocGiaBiKhoaThe();
        //    XReport = prints;
        //    if (File.Exists(GetReportPath(XReport, "repx")))
        //        XReport.LoadLayout(GetReportPath(XReport, "repx"));
        //    prints.Init_XtraDanhSachDocGiaBiKhoaThe(_dtData, _Ngayky);
        //    printControl.PrintingSystem = prints.PrintingSystem;
        //    prints.CreateDocument();
        //}

        //#endregion

        //#region _load_XtraDanhSachDocGiaBiPhat

        //public void _load_XtraDanhSachDocGiaBiPhat(DataTable _dtData, string _Ngayky)
        //{
        //    _dtDataSource = _dtData;
        //    this.Text = "Danh sách đọc giả bị phạt";
        //    XtraReports.XtraDanhSachDocGiaBiPhat prints = new XtraReports.XtraDanhSachDocGiaBiPhat();
        //    XReport = prints;
        //    if (File.Exists(GetReportPath(XReport, "repx")))
        //        XReport.LoadLayout(GetReportPath(XReport, "repx"));
        //    prints.Init_XtraDanhSachDocGiaBiPhat(_dtData, _Ngayky);
        //    printControl.PrintingSystem = prints.PrintingSystem;
        //    prints.CreateDocument();
        //}

        //#endregion

        //#region _load_XtraDanhSachDocGiaMuonSachQuaHan

        //public void _load_XtraDanhSachDocGiaMuonSachQuaHan(DataTable _dtData, string _Ngayky)
        //{
        //    _dtDataSource = _dtData;
        //    this.Text = "Danh sách đọc giả bị phạt";
        //    XtraReports.XtraDanhSachDocGiaMuonSachQuaHan prints = new XtraReports.XtraDanhSachDocGiaMuonSachQuaHan();
        //    XReport = prints;
        //    if (File.Exists(GetReportPath(XReport, "repx")))
        //        XReport.LoadLayout(GetReportPath(XReport, "repx"));
        //    prints.Init_XtraDanhSachDocGiaMuonSachQuaHan(_dtData, _Ngayky);
        //    printControl.PrintingSystem = prints.PrintingSystem;
        //    prints.CreateDocument();
        //}

        //#endregion

        //#region _load_XtraPhieuMuon

        //public void _load_XtraPhieuMuon(DataTable _dtData, string _Ngayky)
        //{
        //    _dtDataSource = _dtData;
        //    this.Text = "Lập phiếu mượn";
        //    XtraReports.XtraPhieuMuon prints = new XtraReports.XtraPhieuMuon();
        //    XReport = prints;
        //    if (File.Exists(GetReportPath(XReport, "repx")))
        //        XReport.LoadLayout(GetReportPath(XReport, "repx"));
        //    prints.Init_XtraPhieuMuon(_dtData, _Ngayky);
        //    printControl.PrintingSystem = prints.PrintingSystem;
        //    prints.CreateDocument();
        //}

        //#endregion

        //#region _load_XtraBienLaiPhat

        //public void _load_XtraBienLaiPhat(DataTable _dtData, string _tongTienPhat, string _Ngayky) //string _Tongtien,
        //{
        //    _dtDataSource = _dtData;
        //    this.Text = "Lập Biên Lai Phạt";
        //    XtraReports.XtraBienLaiPhat prints = new XtraReports.XtraBienLaiPhat();
        //    XReport = prints;
        //    if (File.Exists(GetReportPath(XReport, "repx")))
        //        XReport.LoadLayout(GetReportPath(XReport, "repx"));
        //    prints.Init_XtraBienLaiPhat(_dtData, _tongTienPhat, _Ngayky);
        //    printControl.PrintingSystem = prints.PrintingSystem;
        //    prints.CreateDocument();
        //}

        //#endregion

        //#region _load_XtraDanhSachSachMuon

        //public void _load_XtraDanhSachSachMuon(DataTable _dtData, string _Ngayky)
        //{
        //    _dtDataSource = _dtData;
        //    this.Text = "Danh sách sách đang được mượn";
        //    XtraReports.XtraDanhSachSachMuon prints = new XtraReports.XtraDanhSachSachMuon();
        //    XReport = prints;
        //    if (File.Exists(GetReportPath(XReport, "repx")))
        //        XReport.LoadLayout(GetReportPath(XReport, "repx"));
        //    prints.Init_XtraXtraDanhSachSachMuon(_dtData, _Ngayky);
        //    printControl.PrintingSystem = prints.PrintingSystem;
        //    prints.CreateDocument();
        //}

        //#endregion       

        //#region _load_XtraTKSLSachTheoDauSach
        //public void _load_XtraTKSLSachTheoDauSach(DataTable _dtData, string _Ngayky)
        //{
        //    _dtDataSource = _dtData;
        //    this.Text = "Thống kế số lượng sách theo đầu sách";
            
        //    XtraReports.XtraTKSLSachTheoDauSach prints = new XtraReports.XtraTKSLSachTheoDauSach();
        //    XReport = prints;
        //    if (File.Exists(GetReportPath(XReport, "repx")))
        //        XReport.LoadLayout(GetReportPath(XReport, "repx"));
        //    prints.Init_XtraXtraTKSLSachTheoDauSach(_dtData, _Ngayky);
        //    printControl.PrintingSystem = prints.PrintingSystem;
        //    prints.CreateDocument();
        //}
        //#endregion

        //#region _load_XtraTKSLSachTheoKeSach
        //public void _load_XtraTKSLSachTheoKeSach(DataTable _dtData, string _Ngayky)
        //{
        //    _dtDataSource = _dtData;
        //    this.Text = "Thống kế số lượng sách theo kệ sách";
        //    XtraReports.XtraTKSLSachTheoKeSach prints = new XtraReports.XtraTKSLSachTheoKeSach();
        //    XReport = prints;
        //    if (File.Exists(GetReportPath(XReport, "repx")))
        //        XReport.LoadLayout(GetReportPath(XReport, "repx"));
        //    prints.Init_XtraTKSLSachTheoKeSach(_dtData, _Ngayky);
        //    printControl.PrintingSystem = prints.PrintingSystem;
        //    prints.CreateDocument();
        //}
        //#endregion

        //#region _load_XtraTKSLSachTheoTheLoai
        //public void _load_XtraTKSLSachTheoTheLoai(DataTable _dtData, string _Ngayky)
        //{
        //    _dtDataSource = _dtData;
        //    this.Text = "Thống kế số lượng sách theo thể loại sách";
        //    XtraReports.XtraTKSLSachTheoTheLoai prints = new XtraReports.XtraTKSLSachTheoTheLoai();
        //    XReport = prints;
        //    if (File.Exists(GetReportPath(XReport, "repx")))
        //        XReport.LoadLayout(GetReportPath(XReport, "repx"));
        //    prints.Init_XtraTKSLSachTheoTheLoai(_dtData, _Ngayky);
        //    printControl.PrintingSystem = prints.PrintingSystem;
        //    prints.CreateDocument();
        //}
        //#endregion

        //#region _load_XtraTKSLSachTheoNhaXuatBan
        //public void _load_XtraTKSLSachTheoNhaXuatBan(DataTable _dtData, string _Ngayky)
        //{
        //    _dtDataSource = _dtData;
        //    this.Text = "Thống kế số lượng sách theo nhà xuất bản";
        //    XtraReports.XtraTKSLSachTheoNhaXuatBan prints = new XtraReports.XtraTKSLSachTheoNhaXuatBan();
        //    XReport = prints;
        //    if (File.Exists(GetReportPath(XReport, "repx")))
        //        XReport.LoadLayout(GetReportPath(XReport, "repx"));
        //    prints.Init_XtraTKSLSachTheoNhaXuatBan(_dtData, _Ngayky);
        //    printControl.PrintingSystem = prints.PrintingSystem;
        //    prints.CreateDocument();
        //}
        //#endregion

        #endregion

        #region _load_XtraThephongban
        public void _load_XtraThephongban(DataTable _dtData, string _Ngayky)
        {
            _dtDataSource = _dtData;
            this.Text = "Thống kế tổng số lượng nhân viên theo phòng ban";
            XtraReports.XtraThephongban prints = new XtraReports.XtraThephongban();
            XReport = prints;
            if (File.Exists(GetReportPath(XReport, "repx")))
                XReport.LoadLayout(GetReportPath(XReport, "repx"));
            prints.Init_XtraThephongban(_dtData, _Ngayky);
            printControl.PrintingSystem = prints.PrintingSystem;
            prints.CreateDocument();
        }
        #endregion

        #region _load_XtraTheotrinhdo
        public void _load_XtraTheotrinhdo(DataTable _dtData, string _Ngayky)
        {
            _dtDataSource = _dtData;
            this.Text = "Thống kế tổng số lượng nhân viên theo trình độ";
            XtraReports.XtraTheotrinhdo prints = new XtraReports.XtraTheotrinhdo();
            XReport = prints;
            if (File.Exists(GetReportPath(XReport, "repx")))
                XReport.LoadLayout(GetReportPath(XReport, "repx"));
            prints.Init_XtraTheotrinhdo(_dtData, _Ngayky);
            printControl.PrintingSystem = prints.PrintingSystem;
            prints.CreateDocument();
        }
        #endregion

        #region _load_XtraTuyentheonam
        public void _load_XtraTuyentheonam(DataTable _dtData, string _Ngayky)
        {
            _dtDataSource = _dtData;
            this.Text = "Thống kế tổng số lượng nhân viên tuyển theo năm";
            XtraReports.XtraTuyentheonam prints = new XtraReports.XtraTuyentheonam();
            XReport = prints;
            if (File.Exists(GetReportPath(XReport, "repx")))
                XReport.LoadLayout(GetReportPath(XReport, "repx"));
            prints.Init_XtraTuyentheonam(_dtData, _Ngayky);
            printControl.PrintingSystem = prints.PrintingSystem;
            prints.CreateDocument();
        }
        #endregion

        #region _load_XtraDuockhenthuong
        public void _load_XtraDuockhenthuong(DataTable _dtData, string _Ngayky)
        {
            _dtDataSource = _dtData;
            this.Text = "Danh sách nhân viên được khen thưởng";
            XtraReports.XtraDuockhenthuong prints = new XtraReports.XtraDuockhenthuong();
            XReport = prints;
            if (File.Exists(GetReportPath(XReport, "repx")))
                XReport.LoadLayout(GetReportPath(XReport, "repx"));
            prints.Init_XtraDuockhenthuong(_dtData, _Ngayky);
            printControl.PrintingSystem = prints.PrintingSystem;
            prints.CreateDocument();
        }
        #endregion

        #region _load_XtraBikyluat
        public void _load_XtraBikyluat(DataTable _dtData, string _Ngayky)
        {
            _dtDataSource = _dtData;
            this.Text = "Danh sách nhân viên bị kỹ luật";
            XtraReports.XtraBikyluat prints = new XtraReports.XtraBikyluat();
            XReport = prints;
            if (File.Exists(GetReportPath(XReport, "repx")))
                XReport.LoadLayout(GetReportPath(XReport, "repx"));
            prints.Init_XtraBikyluat(_dtData, _Ngayky);
            printControl.PrintingSystem = prints.PrintingSystem;
            prints.CreateDocument();
        }
        #endregion

        #region _load_XtraDuocnangluong
        public void _load_XtraDuocnangluong(DataTable _dtData, string _Ngayky)
        {
            _dtDataSource = _dtData;
            this.Text = "Danh sách nhân viên bị kỹ luật";
            XtraReports.XtraDuocnangluong prints = new XtraReports.XtraDuocnangluong();
            XReport = prints;
            if (File.Exists(GetReportPath(XReport, "repx")))
                XReport.LoadLayout(GetReportPath(XReport, "repx"));
            prints.Init_XtraDuocnangluong(_dtData, _Ngayky);
            printControl.PrintingSystem = prints.PrintingSystem;
            prints.CreateDocument();
        }
        #endregion
    }
}
